package myky.com.doctorapp.adapter

import android.text.TextUtils
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.facebook.drawee.view.SimpleDraweeView
import myky.com.doctorapp.R
import myky.com.doctorapp.entity.ImageEntity
import myky.com.doctorapp.utils.UriUtils


/**
 * Description:
 * @author wuyangwuyang
 * Created by 2019/1/24 on 10:31
 */
class ImageAdapter(imagelist: List<ImageEntity>) : BaseQuickAdapter<ImageEntity, BaseViewHolder>(R.layout.image_adapter, imagelist) {
    override fun convert(helper: BaseViewHolder?, item: ImageEntity?) {


        helper?.addOnClickListener(R.id.item_layout)

        val del=helper?.getView<ImageView>(R.id.image_deleteIcon)
        val simpleDraweeView = helper?.getView<SimpleDraweeView>(R.id.img_adapter)
        val lin=helper?.getView<LinearLayout>(R.id.image_datebg)
        val path = item?.path

        val uri = UriUtils.getUriInstance().getUri(path)

        simpleDraweeView?.setImageURI(uri)
        //第一张添加图片隐藏布局
        if (TextUtils.isEmpty(path)){
            del?.visibility=View.GONE
            lin?.visibility= View.GONE
        }
        if (item?.illnessName!=null){
            del?.visibility=View.GONE
            lin?.visibility= View.VISIBLE
            helper?.setText(R.id.item_bespeak_datetv,item?.illnessName)
        }

    }
}
